/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mycompany.ingsoc2;

import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;

/**
 *
 * @author sfreiman
 */
public class VcLstPrincipalEliminar implements ActionListener {

    private VcPrincipalView myView;
    private VcPrincipalModel myModel;

    /**
     *
     * @param MV
     * @param MM
     */
    public VcLstPrincipalEliminar(VcPrincipalView MV, VcPrincipalModel MM) {
        this.myView = MV;
        this.myModel = MM;
    }

    /**
     *
     * @param e
     */
    public void actionPerformed(ActionEvent e) {

        int reply = JOptionPane.showConfirmDialog(
                (Component) myView,
                "Estamos Seguros?",
                "Eliminar",
                JOptionPane.YES_NO_OPTION);
        if (reply == JOptionPane.YES_OPTION) {
            try {
                List<Pelicula> listPelis;
            //TODO 2 "For": El primero crea la lista de peliculas, el segundo elimina.
                //Resolucion: 1 solo for llama a la funcion eliminar pelicula.
                this.myModel.eliminarPelicula(this.myView.getSelectedPeliculaID());
                myView.mostrarResultado(this.myModel.listar());
            } catch (SQLException ex) {
                Logger.getLogger(VcLstPrincipalEliminar.class.getName()).log(Level.SEVERE, null, ex);
            }
        }

    }
}
